<template>
	<view class="addEmployee">
		<customTabs type="c1" :value="tabsValue" :animation="true" :defaultTextStyle="{'color':'#333333'}"
			:activeTextStyle="{color:'#000000','font-weight':700}"
			:activeLineStyle="{'background-color':'#3E9BFE',height:'10rpx'}" @change="e=>changeIndex(e)">


			<customTabsPane label="H5跳转" name="c1_1">
				<view class="margin-top_30rpx">

				</view>
				<uni-forms :rules="rulesWxForm" ref="form" :modelValue="form" label-position="top">
					<!-- 	<uni-forms-item label="碰一碰类型" name="code" required labelWidth="360rpx">
						<view class="display-a" style="padding: 30rpx 0 20rpx;">
							<view class="display-a  " @click="getType(1)" style="margin-right: 10rpx;">
								<image class="matrix-12" :src="form.types == 1 ? matrix13 : matrix12"></image>
								<view>短视频营销</view>
							</view>
							<view class="display-a " @click="getType(2)" style="margin-right: 10rpx;">
								<image class="matrix-12" :src="form.types == 2 ? matrix13 : matrix12"></image>
								<view>关注账号</view>
							</view>
							<view class="display-a " @click="getType(3)" style="margin-right: 10rpx;">
								<image class="matrix-12" :src="form.types == 3? matrix13 : matrix12"></image>
								<view>点评种草</view>
							</view>
							<view class="display-a " @click="getType(4)" style="margin-right: 10rpx;">
								<image class="matrix-12" :src="form.types == 4 ? matrix13 : matrix12"></image>
								<view>更多推荐</view>
							</view>
						</view>
					</uni-forms-item> -->



					<uni-forms-item label="应用名称" name="applyName" required labelWidth="360rpx">

						<uni-easyinput v-model="form.applyName" placeholder="请输入应用名称" />

					</uni-forms-item>
					<uni-forms-item label="应用链接" name="applyUrl" required labelWidth="360rpx">
						<uni-easyinput v-model="form.applyUrl" placeholder="请输入应用链接" />

					</uni-forms-item>
					<uni-forms-item label="排序" name="applySort" required labelWidth="360rpx">
						<uni-easyinput type="number" v-model="form.applySort" placeholder="请输入排序" />

					</uni-forms-item>

					<uni-forms-item label="图片" labelWidth="360rpx">

						<!-- <view style="color: #2979ff;margin-bottom: 10rpx;">
							建议上传50 * 200rpx尺寸</view> -->
						<sunui-upimgSelectAll :border="'2rpx dashed #bfbfbf'" :formData="imgFormData" :maxFileNumber="1"
							:storageMode="storageMode" :header="header" :size="['200rpx', '200rpx']" btnName="上传图片"
							:uploadServerUrl="upPicUrl2" ref="selectimgandupload1" @uploaded="e=>imgLoaded2(e,1)"
							@change="e=>imgsChange2(e,1)"><template v-slot:icon>
								<uni-icons type="camera-filled" color="#1890FF" size="40"></uni-icons>
							</template></sunui-upimgSelectAll>

					</uni-forms-item>
					<uni-forms-item label="状态" name="code" required labelWidth="360rpx">
						<view class="display-a" style="padding: 30rpx 0 20rpx;">
							<view class="display-a  " @click="getStatus(1)" style="margin-right: 30rpx;">
								<image class="matrix-12" :src="form.status == 1 ? matrix13 : matrix12"></image>
								<view>开启</view>
							</view>
							<view class="display-a " @click="getStatus(2)" style="margin-right: 10rpx;">
								<image class="matrix-12" :src="form.status == 2 ? matrix13 : matrix12"></image>
								<view>关闭</view>
							</view>

						</view>
					</uni-forms-item>


					<view class="sumbit-btn flex" @click.stop="saveInfo('form')">
						{{ form.id?'修改':'添加'}}配置
					</view>



				</uni-forms>

			</customTabsPane>

			<customTabsPane label="小程序跳转" name="c1_2">

				<uni-forms :rules="rulesWxForm1" ref="form1" :modelValue="form1" label-position="top">
					<uni-forms-item label="应用名称" name="applyName" required labelWidth="360rpx">

						<uni-easyinput v-model="form1.applyName" placeholder="请输入应用名称" />

					</uni-forms-item>
					<uni-forms-item label="小程序appid" name="appId" required labelWidth="360rpx">

						<uni-easyinput v-model="form1.appId" placeholder="请输入小程序appid" />

					</uni-forms-item>
					<uni-forms-item label="小程序名字" name="appName" required labelWidth="360rpx">
						<uni-easyinput v-model="form1.appName" placeholder="请输入小程序名字" />

					</uni-forms-item>
					<uni-forms-item label="小程序Url" name="appUrl" required labelWidth="360rpx">
						<uni-easyinput v-model="form1.appUrl" placeholder="请输入小程序url" />

					</uni-forms-item>
					<uni-forms-item label="排序" name="applySort" required labelWidth="360rpx">
						<uni-easyinput type="number" v-model="form1.applySort" placeholder="请输入排序" />
					
					</uni-forms-item>
					<uni-forms-item label="图片" labelWidth="360rpx">

						<!-- <view style="color: #2979ff;margin-bottom: 10rpx;">
							建议上传50 * 200rpx尺寸</view> -->
						<sunui-upimgSelectAll :border="'2rpx dashed #bfbfbf'" :formData="imgFormData" :maxFileNumber="1"
							:storageMode="storageMode" :header="header" :size="['200rpx', '200rpx']" btnName="上传图片"
							:uploadServerUrl="upPicUrl2" ref="selectimgandupload2" @uploaded="e=>imgLoaded2(e,1)"
							@change="e=>imgsChange2(e,1)"><template v-slot:icon>
								<uni-icons type="camera-filled" color="#1890FF" size="40"></uni-icons>
							</template></sunui-upimgSelectAll>

					</uni-forms-item>
					<uni-forms-item label="状态" name="code" required labelWidth="360rpx">
						<view class="display-a" style="padding: 30rpx 0 20rpx;">
							<view class="display-a  " @click="getStatus1(1)" style="margin-right: 30rpx;">
								<image class="matrix-12" :src="form1.status == 1 ? matrix13 : matrix12"></image>
								<view>开启</view>
							</view>
							<view class="display-a " @click="getStatus1(2)" style="margin-right: 10rpx;">
								<image class="matrix-12" :src="form1.status == 2 ? matrix13 : matrix12"></image>
								<view>关闭</view>
							</view>

						</view>
					</uni-forms-item>
					</uni-forms-item>
				
					<view class="sumbit-btn flex" @click.stop="saveInfo('form1')">
						{{ form1.id?'修改':'添加'}}配置
					</view>
				</uni-forms>

			</customTabsPane>
			<customTabsPane label="拨打电话" name="c1_3">
				<uni-forms :rules="rulesWxForm2" ref="form2" :modelValue="form2" label-position="top">
					<!-- <uni-forms-item label="名称" name="iphoneName" required labelWidth="360rpx">

						<uni-easyinput v-model="form2.iphoneName" placeholder="请输入名称" />

					</uni-forms-item> -->
					<uni-forms-item label="应用名称" name="applyName" required labelWidth="360rpx">

						<uni-easyinput v-model="form2.applyName" placeholder="请输入应用名称" />

					</uni-forms-item>
					<uni-forms-item label="电话号码" name="phone" required labelWidth="360rpx">
						<uni-easyinput v-model="form2.phone " placeholder="请输入电话号码" />

					</uni-forms-item>
					</uni-forms-item>
					<uni-forms-item label="排序" name="applySort" required labelWidth="360rpx">
						<uni-easyinput type="number" v-model="form2.applySort" placeholder="请输入排序" />

					</uni-forms-item>
					<uni-forms-item label="图片" labelWidth="360rpx">

						<!-- <view style="color: #2979ff;margin-bottom: 10rpx;">
							建议上传50 * 200rpx尺寸</view> -->
						<sunui-upimgSelectAll :border="'2rpx dashed #bfbfbf'" :formData="imgFormData" :maxFileNumber="1"
							:storageMode="storageMode" :header="header" :size="['200rpx', '200rpx']" btnName="上传图片"
							:uploadServerUrl="upPicUrl2" ref="selectimgandupload3" @uploaded="e=>imgLoaded2(e,1)"
							@change="e=>imgsChange2(e,1)"><template v-slot:icon>
								<uni-icons type="camera-filled" color="#1890FF" size="40"></uni-icons>
							</template></sunui-upimgSelectAll>

					</uni-forms-item>

					<uni-forms-item label="状态" name="code" required labelWidth="360rpx">
						<view class="display-a" style="padding: 30rpx 0 20rpx;">
							<view class="display-a  " @click="getStatus2(1)" style="margin-right: 30rpx;">
								<image class="matrix-12" :src="form2.status == 1 ? matrix13 : matrix12"></image>
								<view>开启</view>
							</view>
							<view class="display-a " @click="getStatus2(2)" style="margin-right: 10rpx;">
								<image class="matrix-12" :src="form2.status == 2 ? matrix13 : matrix12"></image>
								<view>关闭</view>
							</view>

						</view>
					</uni-forms-item>
					<view class="sumbit-btn flex" @click.stop="saveInfo('form2')">
						{{ form1.id?'修改':'添加'}}配置
					</view>
				</uni-forms>

			</customTabsPane>
			<customTabsPane label="加微信" name="c1_4">
				<uni-forms :rules="rulesWxForm3" ref="form3" :modelValue="form3" label-position="top">
					<!-- <uni-forms-item label="名称" name="iphoneName" required labelWidth="360rpx">
			
						<uni-easyinput v-model="form2.iphoneName" placeholder="请输入名称" />
			
					</uni-forms-item> -->
					<uni-forms-item label="应用名称" name="applyName" required labelWidth="360rpx">

						<uni-easyinput v-model="form3.applyName" placeholder="请输入应用名称" />

					</uni-forms-item>

					</uni-forms-item>
					<uni-forms-item label="排序" name="applySort" required labelWidth="360rpx">
						<uni-easyinput type="number" v-model="form3.applySort" placeholder="请输入排序" />

					</uni-forms-item>

					<uni-forms-item label="图片" labelWidth="360rpx">

						<!-- <view style="color: #2979ff;margin-bottom: 10rpx;">
							建议上传50 * 200rpx尺寸</view> -->
						<sunui-upimgSelectAll :border="'2rpx dashed #bfbfbf'" :formData="imgFormData" :maxFileNumber="1"
							:storageMode="storageMode" :header="header" :size="['200rpx', '200rpx']" btnName="上传图片"
							:uploadServerUrl="upPicUrl2" ref="selectimgandupload4" @uploaded="e=>imgLoaded2(e,1)"
							@change="e=>imgsChange2(e,1)"><template v-slot:icon>
								<uni-icons type="camera-filled" color="#1890FF" size="40"></uni-icons>
							</template></sunui-upimgSelectAll>

					</uni-forms-item>
					<uni-forms-item label="微信二维码" labelWidth="360rpx">


						<sunui-upimgSelectAll :border="'2rpx dashed #bfbfbf'" :formData="imgFormData" :maxFileNumber="1"
							:storageMode="storageMode" :header="header" :size="['200rpx', '200rpx']" btnName="上传图片"
							:uploadServerUrl="upPicUrl2" ref="selectimgandupload5" @uploaded="e=>imgLoaded3(e,2)"
							@change="e=>imgsChange3(e,2)"><template v-slot:icon>
								<uni-icons type="camera-filled" color="#1890FF" size="40"></uni-icons>
						</template></sunui-upimgSelectAll>

					</uni-forms-item>
					<uni-forms-item label="状态" name="code" required labelWidth="360rpx">
						<view class="display-a" style="padding: 30rpx 0 20rpx;">
							<view class="display-a  " @click="getStatus3(1)" style="margin-right: 30rpx;">
								<image class="matrix-12" :src="form3.status == 1 ? matrix13 : matrix12"></image>
								<view>开启</view>
							</view>
							<view class="display-a " @click="getStatus3(2)" style="margin-right: 10rpx;">
								<image class="matrix-12" :src="form3.status == 2 ? matrix13 : matrix12"></image>
								<view>关闭</view>
							</view>

						</view>
					</uni-forms-item>
					<view class="sumbit-btn flex" @click.stop="saveInfo('form3')">
						{{ form1.id?'修改':'添加'}}配置
					</view>
				</uni-forms>

			</customTabsPane>
			<customTabsPane label="连接WiFi" name="c1_5">
				<uni-forms :rules="rulesWxForm4" ref="form4" :modelValue="form4" label-position="top">
					<!-- <uni-forms-item label="名称" name="iphoneName" required labelWidth="360rpx">
            
            			<uni-easyinput v-model="form2.iphoneName" placeholder="请输入名称" />
            
            		</uni-forms-item> -->
					<uni-forms-item label="应用名称" name="applyName" required labelWidth="360rpx">

						<uni-easyinput v-model="form4.applyName" placeholder="请输入应用名称" />

					</uni-forms-item>

					</uni-forms-item>
					<uni-forms-item label="排序" name="applySort" required labelWidth="360rpx">
						<uni-easyinput type="number" v-model="form4.applySort" placeholder="请输入排序" />

					</uni-forms-item>

					<uni-forms-item label="WiFi名称" name="wifiName" required labelWidth="360rpx">
						<uni-easyinput type="number" v-model="form4.wifiName" placeholder="请输入WiFi名称" />

					</uni-forms-item>
					<uni-forms-item label="WiFi密码" name="wifiPassword" required labelWidth="360rpx">
						<uni-easyinput type="password" v-model="form4.wifiPassword" placeholder="请输入WiFi密码" />

					</uni-forms-item>
					<uni-forms-item label="图片" labelWidth="360rpx">

						<!-- <view style="color: #2979ff;margin-bottom: 10rpx;">
            				建议上传50 * 200rpx尺寸</view> -->
						<sunui-upimgSelectAll :border="'2rpx dashed #bfbfbf'" :formData="imgFormData" :maxFileNumber="1"
							:storageMode="storageMode" :header="header" :size="['200rpx', '200rpx']" btnName="上传图片"
							:uploadServerUrl="upPicUrl2" ref="selectimgandupload6" @uploaded="e=>imgLoaded2(e,1)"
							@change="e=>imgsChange2(e,1)"><template v-slot:icon>
								<uni-icons type="camera-filled" color="#1890FF" size="40"></uni-icons>
							</template></sunui-upimgSelectAll>

					</uni-forms-item>
					<uni-forms-item label="WiFi连接码" labelWidth="360rpx">


						<sunui-upimgSelectAll :border="'2rpx dashed #bfbfbf'" :formData="imgFormData" :maxFileNumber="1"
							:storageMode="storageMode" :header="header" :size="['200rpx', '200rpx']" btnName="上传图片"
							:uploadServerUrl="upPicUrl2" ref="selectimgandupload7" @uploaded="e=>imgLoaded3(e,2)"
							@change="e=>imgsChange3(e,2)"><template v-slot:icon>
								<uni-icons type="camera-filled" color="#1890FF" size="40"></uni-icons>
							</template></sunui-upimgSelectAll>

					</uni-forms-item>
					<uni-forms-item label="状态" name="code" required labelWidth="360rpx">
						<view class="display-a" style="padding: 30rpx 0 20rpx;">
							<view class="display-a  " @click="getStatus4(1)" style="margin-right: 30rpx;">
								<image class="matrix-12" :src="form4.status == 1 ? matrix13 : matrix12"></image>
								<view>开启</view>
							</view>
							<view class="display-a " @click="getStatus4(2)" style="margin-right: 10rpx;">
								<image class="matrix-12" :src="form4.status == 2 ? matrix13 : matrix12"></image>
								<view>关闭</view>
							</view>

						</view>
					</uni-forms-item>
					<view class="sumbit-btn flex" @click.stop="saveInfo('form4')">
						{{ form1.id?'修改':'添加'}}配置
					</view>
				</uni-forms>

			</customTabsPane>


		</customTabs>


		<lb-picker ref="picker2" v-model="value2" mode="multiSelector" confirmColor="#6568F6" :list="regionList"
			:props="factoryProp" :level="2" @change="handleChange" @confirm="handleConfirm" @cancel="handleCancel">
			<template>
				<view slot="action-center">选择城市</view>
			</template>
		</lb-picker>

	</view>
</template>

<script>
	import regionLists from '@/utils/region-picker.js';
	// import  custom-tabs from '.'
	import customTabsPane from '../../uni_modules/custom-tabs/components/custom-tab-pane/custom-tab-pane.vue';
	import customTabs from '../../uni_modules/custom-tabs/components/custom-tabs/custom-tabs.vue';
	require('@/utils/ali-oos/hmac.js');
	require('@/utils/ali-oos/hmac.js');
	require('@/utils/ali-oos/sha1.js');
	const Crypto = require('@/utils/ali-oos/crypto.js');
	const base64 = require('@/utils/ali-oos/base64.js'); 
	export default {
		components: {
			// custom-tabs
			customTabs,
			customTabsPane

		},
		data() {
			return {
				tabsValue: '0',

				imgStr2: [],
				img2: [],
				upPicUrl2: '',
				imgFormData: null,
				storageMode: 2,
				ossInfo: {},
				header: '',
				timeDate: '',
				suffix: '',
				formData: {
					key: '',
					policy: '',
					OSSAccessKeyId: '',
					signature: '',
					success_action_status: '200'
				},


				factoryProp: {
					label: 'name',
					value: 'id'
				},
				keyword: "",
				cityName: '',
				isDy: '',
				regionList: regionLists.zones_tree,
				city: '',
				value2: [],
				poiList: [],
				groupType: 1,
				// 商家id
				merchantId: uni.getStorageSync('merchantId'),
				
				matrix12: this.$imgs.matrix12Five,
				matrix13: this.$imgs.matrix13Five,


				obj: {
					libType: 1,
					numberCount: 0,
					linkType: 1

				},
				projectList: [],
				policyText: {
					expiration: '2050-01-01T12:00:00.000Z', //设置该Policy的失效时间，超过这个失效时间之后，就没有办法通过这个policy上传文件了
					conditions: [
						['content-length-range', 0,
							314572800
						] // 设置上传文件的大小限制(104857600为：100MB，31457280为30MB:[计算 300MB*1024*1024])
					]
				},
				// 商家注册
				form: {
					types: 4,

					// 应用名称
					applyName: '',
					// 图片地址
					imageUrl: '',
					// 应用链接

					applyUrl: '',
					// 开启关闭
					status: 1,

					id: '',
					applySort: '',
					// 1 h5跳转 2小程序跳转 3.拨打电话 4加微信  5连接WiFi
					jumpForm: '1',
					appId: '',
					appName: '',
					appUrl: '',
					phone: '',
					videoUrl: null,
					wifiName: null,
					wifiPassword: null




				},
				form1: {
					types: 4,

					// 应用名称
					applyName: '',
					// 图片地址
					imageUrl: '',
					// 应用链接

					applyUrl: '',
					// 开启关闭
					status: 1,

					id: '',
					applySort: '',
					// 1 h5跳转 2小程序跳转 3.拨打电话
					jumpForm: '1',
					appId: '',
					appName: '',
					appUrl: '',
					phone: '',
					videoUrl: null,
					wifiName: null,
					wifiPassword: null




				},
				form2: {
					types: 4,

					// 应用名称
					applyName: '',
					// 图片地址
					imageUrl: '',
					// 应用链接

					applyUrl: '',
					// 开启关闭
					status: 1,

					id: '',
					applySort: '',
					// 1 h5跳转 2小程序跳转 3.拨打电话
					jumpForm: '1',
					appId: '',
					appName: '',
					appUrl: '',
					phone: '',
					videoUrl: null,
					wifiName: null,
					wifiPassword: null




				},
				form3: {
					types: 4,

					// 应用名称
					applyName: '',
					// 图片地址
					imageUrl: '',
					// 应用链接

					applyUrl: '',
					// 开启关闭
					status: 1,

					id: '',
					applySort: '',
					// 1 h5跳转 2小程序跳转 3.拨打电话
					jumpForm: '1',
					appId: '',
					appName: '',
					appUrl: '',
					phone: '',

					videoUrl: null,
					wifiName: null,
					wifiPassword: null




				},
				form4: {
					types: 4,

					// 应用名称
					applyName: '',
					// 图片地址
					imageUrl: '',
					// 应用链接

					applyUrl: '',
					// 开启关闭
					status: 1,

					id: '',
					applySort: '',
					// 1 h5跳转 2小程序跳转 3.拨打电话
					jumpForm: '1',
					appId: '',
					appName: '',
					appUrl: '',
					phone: '',

					videoUrl: null,
					wifiName: null,
					wifiPassword: null




				},
				count: 0,
				disableCode: false,

				codeVerification: '',
				rulesWxForm: {

					applyName: {
						rules: [{
							required: true,
							errorMessage: '请输入应用名称'
						}]
					},
					applyUrl: {
						rules: [{
							required: true,
							errorMessage: '请输入应用链接'
						}]
					},
					applySort: {
						rules: [{
							required: true,
							errorMessage: '请输入排序'
						}]

					},


				},
				rulesWxForm1: {
					applyName: {
						rules: [{
							required: true,
							errorMessage: '请输入应用名称'
						}]
					},
					appId: {
						rules: [{
							required: true,
							errorMessage: '请输入小程序appid'
						}]
					},
					appName: {
						rules: [{
							required: true,
							errorMessage: '请输入小程序名字'
						}]
					},
					applySort: {
						rules: [{
							required: true,
							errorMessage: '请输入排序'
						}]

					},
					appUrl: {
						rules: [{
							required: true,
							errorMessage: '请输入小程序url'
						}]

					}

				},
				rulesWxForm2: {
					applyName: {
						rules: [{
							required: true,
							errorMessage: '请输入应用名称'
						}]
					},
					iphoneName: {
						rules: [{
							required: true,
							errorMessage: '请输入名字'
						}]
					},
					phone: {
						rules: [{
							required: true,
							errorMessage: '请输入电话号码'
						}]
					},
					applySort: {
						rules: [{
							required: true,
							errorMessage: '请输入排序'
						}]

					},



				},
				rulesWxForm3: {
					applyName: {
						rules: [{
							required: true,
							errorMessage: '请输入应用名称'
						}]
					},


					applySort: {
						rules: [{
							required: true,
							errorMessage: '请输入排序'
						}]

					},



				},
				rulesWxForm4: {
					applyName: {
						rules: [{
							required: true,
							errorMessage: '请输入应用名称'
						}]
					},


					applySort: {
						rules: [{
							required: true,
							errorMessage: '请输入排序'
						}]

					},
					wifiName: {
						rules: [{
							required: true,
							errorMessage: '请输入WIFI名称'
						}]

					},
					wifiPassword: {
						rules: [{
							required: true,
							errorMessage: '请输入WIFI密码'
						}]

					},


				},


			}
		},

		onLoad(options) {
			console.log(options)
			if (Object.keys(options).length) {
				console.log(JSON.parse(decodeURIComponent((options.info))), options)

				this.isDy = (options.isDy == 1) ? true : false
				if (Number(JSON.parse(decodeURIComponent((options.info))).jumpForm) == 0 || Number(JSON.parse(
						decodeURIComponent((options.info))).jumpForm) == 1) {
					this.tabsValue = 0
				} else {
					this.tabsValue = Number(JSON.parse(decodeURIComponent((options.info))).jumpForm) - 1
				}
				const data = JSON.parse(decodeURIComponent((options.info))).jumpForm == 1 || JSON.parse(decodeURIComponent(
						(options.info))).jumpForm == 0 ? this.form : JSON.parse(decodeURIComponent((options.info)))
					.jumpForm == 2 ? this.form1 : JSON.parse(decodeURIComponent((options.info)))
					.jumpForm == 3?this.form2:JSON.parse(decodeURIComponent((options.info)))
					.jumpForm == 4?this.form3:this.form4
				console.log(data)
				this.$sun.assignObject(data, {
					...JSON.parse(decodeURIComponent((options.info)))
				})

				const imgStr2 = data.imageUrl

				const imgStr3 = data.videoUrl

				if (imgStr2.length) {
					if (imgStr2.includes(',')) {
						console.log('字符串中包含逗号');
						// 包含的进行slice(',') 分割

						this.imgStr2 = imgStr2.split(',').map((item) => item.trim());
						if (this.tabsValue == 0) {
							this.$refs.selectimgandupload1.setItems(this.imgStr2);
						} else if (this.tabsValue == 1) {
							this.$refs.selectimgandupload2.setItems(this.imgStr2);
						} else if (this.tabsValue == 2) {
							this.$refs.selectimgandupload3.setItems(this.imgStr2);
						} else if (this.tabsValue == 3) {
							this.$refs.selectimgandupload4.setItems(this.imgStr2);
							this.$refs.selectimgandupload5.setItems([imgStr3]);
						}else if (this.tabsValue == 4) {
							this.$refs.selectimgandupload6.setItems(this.imgStr2);
							this.$refs.selectimgandupload7.setItems([imgStr3]);
						}

					} else {
						console.log('字符串中不包含逗号');
						this.imgStr2 = imgStr2.split();
						if (this.tabsValue == 0) {
							this.$refs.selectimgandupload1.setItems(this.imgStr2);
						} else if (this.tabsValue == 1) {
							this.$refs.selectimgandupload2.setItems(this.imgStr2);
						} else if (this.tabsValue == 2) {
							this.$refs.selectimgandupload3.setItems(this.imgStr2);
						} else if (this.tabsValue == 3) {
							this.$refs.selectimgandupload4.setItems(this.imgStr2);
							this.$refs.selectimgandupload5.setItems([imgStr3]);
						}else if (this.tabsValue == 4) {
							this.$refs.selectimgandupload6.setItems(this.imgStr2);
							this.$refs.selectimgandupload7.setItems([imgStr3]);
						}
					}


				}
			}

			this.form.types = 4
			console.log(this.form)
			// this.set()

			// this.getProject()



		},
		methods: {
			changeIndex(e) {
				console.log(e.value)
				this.tabsValue = e.value;

				(this.tabsValue == 0) ? this.form.jumpForm = 1: this.tabsValue == 1 ? this.form1.jumpForm = 2 : this
					.tabsValue == 2 ? this.form2.jumpForm = 3 : this.tabsValue == 3 ? this.form3.jumpForm = 4 : this.form4
					.jumpForm = 5;
			},
			async set() {
				const result = await this.$http.get({
					url: this.$api.userOssSignature,
					data: {
						merchantId: uni.getStorageSync('merchantId')
					}
				});
				if (result.code == 2000) {
					// accessKey 阿里云key秘钥 accessId 阿里云id
					console.log('result', result);
					this.upPicUrl2 = result.data.host;
					this.formData.OSSAccessKeyId = result.data.accessId;
					this.formData.policy = base64.encode(JSON.stringify(this.policyText));
					let message = this.formData.policy;
					let bytes = Crypto.HMAC(Crypto.SHA1, message, result.data.accessKey, {
						asBytes: true
					});
					this.formData.signature = Crypto.util.bytesToBase64(bytes);

					console.log('------------formData', this.formData);
				}
			},
			delayLoop(file, i, imgIndex) {

				if (i >= file.length) {

					return;
				}

				if (file.length) {
					this.timeDate = new Date().getTime();

					let fileUrl = file[0].url;
					console.log(fileUrl)
					let markIndex = fileUrl.lastIndexOf('.');
					// this.suffix = fileUrl.substring(markIndex); //后缀
					this.suffix = '.png'

					console.log('this.ossInfo', this.ossInfo);
					this.imgFormData = {
						name: this.timeDate + this.suffix,
						key: this.timeDate + this.suffix, //上传图片的名字和路径（默认路径根目录，自定义目录：xxx/xxx.png）
						policy: this.ossInfo.policy,
						OSSAccessKeyId: this.ossInfo.accessId,
						success_action_status: '200',
						signature: this.ossInfo.signature
					};
					this.header = {
						'Access-Control-Allow-Origin': '*',
						'x-oss-callback-Authorization': 'access_token'
					};
					this.$nextTick(() => {
						if (this.tabsValue == 0) {
							this.$refs.selectimgandupload1.upload()
						} else if (this.tabsValue == 1) {
							this.$refs.selectimgandupload2.upload()
						} else if (this.tabsValue == 2) {
							this.$refs.selectimgandupload3.upload()
						} else if (this.tabsValue == 3) {
							if (imgIndex == 1) {

								this.$refs.selectimgandupload4.upload()
							} else {
								this.$refs.selectimgandupload5.upload()
							}

						} else if (this.tabsValue == 4) {
							// this.form3.imageUrl = this.imgStr2[0]
							if (imgIndex == 1) {
								this.$refs.selectimgandupload6.upload()
							} else {
								this.$refs.selectimgandupload7.upload()
							}

						}

					});
					console.log('页面阿里云url22222222222222', this.ossInfo?.host + '/' + this.timeDate + this.suffix);

				} else {
					if (this.tabsValue == 0) {
						this.form.imageUrl = ''
					} else if (this.tabsValue == 1) {
						this.form1.imageUrl = ''
					} else if (this.tabsValue == 2) {
						this.form2.imageUrl = ''
					} else if (this.tabsValue == 3) {
						this.form3.imageUrl = ''
					} else if (this.tabsValue == 4) {
						this.form4.imageUrl = ''
					}
				}

				setTimeout(() => {
					this.delayLoop(file, i + 1);
				}, 500);
			},
			async userOssSignature(file, imgIndex = 1) {

				console.log('this阿里云上传进入=======');
				const ts = new Date().getTime();
				const us = {
					ts
				};

				const res = await this.$http.get({
					url: this.$api.userOssSignature,
					data: {
						merchantId: uni.getStorageSync('merchantId'),
					}
				});
				this.ossInfo = res.data;
				this.upPicUrl2 = this.ossInfo?.host;
				// 获取上传图片名称和后缀
				console.log(file)

				if (file.length) {
					this.delayLoop(file, 0, imgIndex);

				} else {
					if (this.tabsValue == 0) {
						this.form.imageUrl = ''
					} else if (this.tabsValue == 1) {
						this.form1.imageUrl = ''
					} else if (this.tabsValue == 2) {
						this.form2.imageUrl = ''
					} else if (this.tabsValue == 3) {
						this.form3.imageUrl = ''
					} else if (this.tabsValue == 4) {
						this.form4.imageUrl = ''
					}

				}



			},
			imgLoaded2(e, itype) {
				console.log('上传返回eeeee111============', e, itype);
				try {
					this.img2 = [];
					for (let i = 0; i < e.length; i++) {

						this.img2.push(e[i].url);
					}
				} catch (e) {
					this.img2 = [];
				}

				this.imgStr2 = this.img2
				console.log(this.imgStr2)

				if (this.tabsValue == 0) {
					this.form.imageUrl = this.imgStr2[0]
				} else if (this.tabsValue == 1) {
					this.form1.imageUrl = this.imgStr2[0]
				} else if (this.tabsValue == 2) {
					this.form2.imageUrl = this.imgStr2[0]
				} else if (this.tabsValue == 3) {
					// this.form3.imageUrl = this.imgStr2[0]
					if (itype == 1) {
						this.form3.imageUrl = this.imgStr2[0]
					} else {
						this.form3.videoUrl = this.imgStr2[0]
					}

				} else if (this.tabsValue == 4) {
					// this.form3.imageUrl = this.imgStr2[0]
					if (itype == 1) {
						this.form4.imageUrl = this.imgStr2[0]
					} else {
						this.form4.videoUrl = this.imgStr2[0]
					}

				}

				console.log(this.form.imageUrl)


			},
			imgLoaded3(e, itype) {
				console.log('上传返回eeeee111============', e, itype);
				try {
					this.img2 = [];
					for (let i = 0; i < e.length; i++) {

						this.img2.push(e[i].url);
					}
				} catch (e) {
					this.img2 = [];
				}

				this.imgStr2 = this.img2
				console.log(this.imgStr2)

				if (this.tabsValue == 0) {
					this.form.imageUrl = this.imgStr2[0]
				} else if (this.tabsValue == 1) {
					this.form1.imageUrl = this.imgStr2[0]
				} else if (this.tabsValue == 2) {
					this.form2.imageUrl = this.imgStr2[0]
				} else if (this.tabsValue == 3) {
					// this.form3.imageUrl = this.imgStr2[0]
					if (itype == 1) {
						this.form3.imageUrl = this.imgStr2[0]
					} else {
						this.form3.videoUrl = this.imgStr2[0]
					}

				} else if (this.tabsValue == 4) {
					// this.form3.imageUrl = this.imgStr2[0]
					if (itype == 1) {
						this.form4.imageUrl = this.imgStr2[0]
					} else {
						this.form4.videoUrl = this.imgStr2[0]
					}

				}

				console.log(this.form.imageUrl)


			},
			imgsChange2(file, index = 1) {


				// 文件名
				this.timeDate = new Date().getTime();
				console.log('上传发生改变this.storageMode11111============', this.storageMode, '参数file', file);

				// 如果是2 上传  阿里云 3  七牛云
				if (this.storageMode == 2) {
					this.userOssSignature(file, index);
				}

			},
			imgsChange3(file, index) {


				// 文件名
				this.timeDate = new Date().getTime();
				console.log('上传发生改变this.storageMode11111============', this.storageMode, '参数file', file);

				// 如果是2 上传  阿里云 3  七牛云
				if (this.storageMode == 2) {
					this.userOssSignature(file, index);
				}

			},
			//抖音挂载类型
			selMountType(type) {
				// notTransfer: '是否开启中转1.否 2.是 待用户发布&& 开启中转_ 禁用
				// if (this.type == 3 && this.notTransfer == 2) {
				// 	return
				// }


				this.obj.linkType = type;
			},

			//选择POI地址
			bindPickerChange3(e) {
				this.form.poiId = this.poiList[e.detail.value].poi_id; //商家POI Id
				this.form.poiName = this.poiList[e.detail.value].poi_name; //POI地址名称
			},
			handleCancel(e) {
				console.log('cancel::', e);
			},
			//选择城市
			handleRegion() {
				this.$refs['picker2'].show();
			},
			//选择城市
			handleChange(e) {
				console.log(e);
			},
			handleConfirm(e) {
				let index = e.index;
				let firstIndex = index[0];
				let secondIndex = index[1];
				// let thridIndex = index[2];

				// let firstStatus = this.regionList[firstIndex];
				let secondStatus = this.regionList[firstIndex].children[secondIndex];
				// let thridStatus = this.regionList[firstIndex].children[secondIndex].children[thridIndex];
				this.cityName = secondStatus.name;
				this.city = secondStatus.code;
			},

			async getPoiList() {
				if (!this.city) {
					this.$sun.toast('请选择城市', 'none');
					return;
				}

				if (!this.keyword) {
					this.$sun.toast('请输入商家简称', 'none');
					return;
				}

				const result = await this.$http.get({
					url: this.$api.getPoi,
					data: {
						username: uni.getStorageSync('staffCode'),
						keyword: this.keyword,
						city: this.city
					}
				});
				if (result.code == 2000) {
					this.poiList = result.data.data.pois;
				} else {
					this.$sun.toast(result.msg, 'none');
				}
			},

			//素材文件
			bindPickerChange(e) {
				this.form.projectName = this.projectList[e.detail.value].name;
				this.form.projectId = this.projectList[e.detail.value].id;
				if (this.obj.libType == 1) {
					this.obj.numberCount = this.projectList[e.detail.value].countNumber;
				}
				if (this.obj.libType == 2) {
					this.obj.numberCount = this.projectList[e.detail.value].jjCount;
				}
			},
			//素材文件
			async getProject() {




				let data = null;
				let getUrl = '';
				if (this.obj.libType == 1) {
					getUrl = this.$api.projectPage;
					data = {
						username: uni.getStorageSync('staffCode')
					};
				}
				if (this.obj.libType == 2) {
					getUrl = this.$api.queryFiles;
					data = {
						merchantId: uni.getStorageSync('merchantId'),
						types: 1
					};
				}


				const result = await this.$http.post({
					url: getUrl,
					data: data
				});
				if (result.code == 2000) {

					this.projectList = result.data;
					if (this.obj.libType == 2) {
						for (let i = 0; i < this.projectList.length; i++) {
							this.projectList[i].name = this.projectList[i].projectName;
						}


					}
					if (this.form.projectId) {
						const projectIdObj = this.projectList.find(item => item.id == this.form.projectId)

						this.obj.numberCount = projectIdObj.countNumber
					}
				} else {
					this.$sun.toast(result.msg, 'none');
				}

			},
			//分组类型
			getType(type) {

				this.form.types = type
			},
			getStatus(status) {
				this.form.status = status
			},
			getStatus1(status) {
				this.form1.status = status
			},
			getStatus2(status) {
				this.form2.status = status
			},
			getStatus3(status) {
				this.form3.status = status
			},
			getStatus4(status) {
				this.form4.status = status
			},
			// 验证码码倒计60秒
			countDown(seconds) {
				this.count = seconds;
				var countdownTimer = setInterval(() => {

					this.count--;
					if (this.count === 0) {
						clearInterval(countdownTimer);
						this.disableCode = false
						// 在这里可以触发验证码过期后的操作
					}
				}, 1000);
			},
			// 登录
			async getVerificationCode() {
				if (!this.disableCode) {




				}


			},
			saveInfo(formName) {

				console.log(this.form3, this.form4)
				this.$refs[formName].validate((err, formData) => {
					console.log(err, formData)
					if (err) {
						console.log(err, formData)
						return
					} else {

						const data = this.tabsValue == 0 ? this.form : this.tabsValue == 1 ? this.form1 : this
							.tabsValue == 2 ? this
							.form2 : this.tabsValue == 3 ? this.form3 : this.form4
						console.log(data)
						if (!(data.imageUrl)) {
							this.$sun.toast('请上传图片', 'none');
							return
						}
						if (this.tabsValue == 3||this.tabsValue == 4) {
							if(!(data.videoUrl)){
								
								this.$sun.toast('请上传图片', 'none');
								return
							}
							
						}
						this.$at.uniDoFunc({
							key: 'release',
							success: async () => {
								this.$at.lockKey('release');
								const result = await this.$http.post({
									url: this.$api.touchAdd,
									data: {
										...data,
										id: data.id ? data.id : undefined,
										applySort: Number(data.applySort),
										merchantId: uni.getStorageSync('merchantId'),
									},


								});

								if (result.code == 2000) {
									setTimeout(() => {
										this.$sun.toast(result.msg, 'none')
									}, 500)
									this.$sun.navBack()
									this.$at.releaseKey('release');

								} else {
									this.$sun.toast(result.msg, 'none')
									this.$at.releaseKey('release');
								}


								this.$at.releaseKey('release');

							}
						});
					}


				}).then(async res => {
					this.$at.uniDoFunc({
						key: 'release',
						success: async () => {
							this.$at.lockKey('release');


							this.$at.releaseKey('release');
						}
					});


				})

			},
		}
	}
</script>

<style lang="less" scoped>
	::v-deep .uni-forms-item {
		width: 700rpx
	}

	::v-deep .tab-pane {
		width: 702rpx !important
	}

	page {
		background-color: #fff;
	}

	.input-name {
		width: 800rpx;
		padding: 20rpx;
		border: 2rpx solid #d9d9d9;
		border-radius: 10rpx;
		background-color: #FFF;
	}

	.list-public {
		padding: 30rpx;
	}

	.matrix-13 {
		width: 36rpx;
		height: 36rpx;
		margin-right: 8rpx;
	}

	.addEmployee {
		padding: 25rpx 25rpx 125rpx 25rpx;
		background-color: #FFF;

		.matrix-12 {
			width: 40rpx;
			height: 40rpx;
			margin-right: 10rpx;
		}

		.matrix-20 {
			width: 18rpx;
			height: 30rpx;
			margin-left: auto;
		}

		.iphone {
			position: relative;

			.verificationCode {
				z-index: 999;
				position: absolute;
				top: 3rpx;
				right: -8rpx;
				text-align: center;
				width: 170rpx;
				height: 70rpx;
				line-height: 70rpx;

				font-size: 20rpx;
				background: #1E6CEB;
				color: #FFF;

			}
		}

		.search {
			width: 140rpx;
			text-align: center;
			background-color: #6568f6;
			color: #ffffff;
			padding: 20rpx;
		}

		.sumbit-btn {
			width: 693rpx;
			// position: fixed;
			z-index: 9999;
			bottom: 50rpx;

			height: 100rpx;
			color: #fff;
			border-radius: 20rpx;

			background-color: #1890FF;
		}
	}
</style>